package logic

import (
	"context"
	"moxue_rpc/mysql"

	"moxue_rpc/internal/svc"
	"moxue_rpc/moxue"

	"github.com/zeromicro/go-zero/core/logx"
)

type UpdateOrderStateLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUpdateOrderStateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateOrderStateLogic {
	return &UpdateOrderStateLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *UpdateOrderStateLogic) UpdateOrderState(in *moxue.UpdateOrderStateRequest) (*moxue.UpdateOrderStateResponse, error) {
	// todo: add your logic here and delete this line
	var o mysql.Order
	err := o.UpdateState(in.OrderNo, int(in.State))
	if err != nil {
		return nil, err
	}

	return &moxue.UpdateOrderStateResponse{}, nil
}
